package ch.exm.storm.conditions;

import ch.exm.storm.conditions.arguments.EvaluatedArgument;
import ch.exm.storm.query.relational.RelationalQuery;

public abstract class OneArgumentCondition extends AbstractSimpleCondition {

	protected OneArgumentCondition(Object argument) {
		arguments = new Object[] { argument };
	}		
	
	@Override
	public boolean evaluateRelationalCondition(RelationalQuery query, boolean inverse) {
		whereCondition = new StringBuilder();
		EvaluatedArgument evaluatedArgument = evaluateArgument(arguments[0], query);
		if (!evaluatedArgument.isFullyEvaluated()) {
			whereCondition.setLength(0);
			return false;
		}
		whereCondition.append(inverse ? getInverseConditionKeyword() : getConditionKeyword());
		return true;
	}
}
